/**
 * @Author: wangliuyang
 * @Date: 2021/9/6 22:19
 * @Description:62. 不同路径
 */
public class Solution_62 {
    public int uniquePaths(int m, int n) {
        if (m == 1 || n == 1){
            return 1;
        }
        int up = 1;
        int down = 1;
        for (int i = 0; i < n + m - 2; i++) {
            up *= (n + m - 2 - i);
        }
        int min = Math.min(n,m);
        for (int i = 1;i <=min; i++){
            down *= i;
        }
        return up / down;
    }
}
